package operator;

/**
 * @author shkstart
 * @date 2022/3/30 - 22:00
 */
public class ModuloAndDivisionOperations {
    public static void main(String[] args) {
//        除号：/
        int num1 = 20;
        int num2 = 6;
        int result1 = num1 / num2;
        System.out.println("result1 = " + result1);

        int result2 = num1 / num2 * num2;
        System.out.println("result2 = " + result2);

        double result3 = num1 / num2;
        System.out.println("result3 = " + result3);

        double result4 = num1 / num2 + 0.0;
        double result5 = num1 / (num2 + 0.0);
        double result6 = (double)num1 / num2;
        double result7 = (double)(num1 / num2);
        System.out.println(result5);
        System.out.println(result6);

//        %:取余运算
//        结果符号与被模数的符号相同
//        开发中，经常用%来判断能否被除尽的情况。

        int m1 = 20;
        int n1 = 6;
        System.out.println("m1 % n1 = " + m1 % n1);

        int m2 = -20;
        int n2 = 6;
        System.out.println("m2 % n2 = " + m2 % n2);

        int m3 = 20;
        int n3 = -6;
        System.out.println("m3 % n3 = " + m3 % n3);

        int m4 = -20;
        int n4 = -6;
        System.out.println("m4 % n4 = " + m4 % n4);

    }

}
